package com.agger.harmonyosthemeseditor.abilities.slices;

import com.agger.harmonyosthemeseditor.ResourceTable;
import com.agger.harmonyosthemeseditor.ThemesEditorAbility;
import com.agger.harmonyosthemeseditor.abilities.PreloadServiceAbility;
import com.agger.harmonyosthemeseditor.intelligent.DatabaseManager;
import com.agger.harmonyosthemeseditor.intelligent.GeneralUtil;
import com.agger.harmonyosthemeseditor.userinterface.GeneralToast;
import com.agger.harmonyosthemeseditor.userinterface.PageSwiper;
import com.agger.harmonyosthemeseditor.userinterface.ResourceTool;
import com.agger.harmonyosthemeseditor.userinterface.TitleSwiper;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.ability.AbilitySliceAnimator;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.Component;
import ohos.agp.components.Image;
import ohos.agp.components.PageSlider;
import ohos.agp.components.Text;
import ohos.agp.components.element.VectorElement;
import ohos.agp.utils.Color;
import ohos.agp.window.service.DisplayAttributes;
import ohos.agp.window.service.DisplayManager;
import ohos.agp.window.service.WindowManager;
import ohos.eventhandler.EventHandler;
import ohos.eventhandler.EventRunner;
import ohos.eventhandler.InnerEvent;
import ohos.miscservices.wallpaper.WallpaperController;
import ohos.os.ProcessManager;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;

public class MainSceneSlice extends AbilitySlice
{
    private static EventRunner runner;
    private static MyEventHandler myHandler;
    private String Toast_QuitApplication = "再按一次退出";
    public PageSlider AllTitles;
    public static PageSlider AllPages;
    public PageSwiper pageSwiper;
    private Text text_home,text_industry,text_more;
    private Image image_home,image_industry,image_more;
    public static boolean EnableBottomSlide = false;
    public static int current_Direction;
    public static MainSceneSlice Instance;
    private InitPageHandler eventHandler;
    //private Component AllContent;
    //private AnimatorValue animator;

    private class MyEventHandler extends EventHandler
    {
        private MyEventHandler(EventRunner runner) {
            super(runner);
        }
        @Override
        public void processEvent(InnerEvent event)
        {
            if(event==null)return;
            super.processEvent(event);
            ThemesEditorAbility.isQuitMode = false;
        }
    }

    //划重点！！！不要随便用postTask，它有些时候可能自己bug不会执行，尽量别偷懒，多用Handler重写，这个一定能执行！！！
    private class InitPageHandler extends EventHandler
    {
        private InitPageHandler(EventRunner runner) {
            super(runner);
        }
        @Override
        public void processEvent(InnerEvent event)
        {
            if(event==null)return;
            super.processEvent(event);
            initPage(event.eventId);
        }
    }

    private class AbilitySliceAnimatorHandler extends EventHandler
    {
        private AbilitySliceAnimatorHandler(EventRunner runner) {
            super(runner);
        }
        @Override
        public void processEvent(InnerEvent event)
        {
            if(event==null)return;
            super.processEvent(event);
            try
            {
                AbilitySliceAnimator abilitySliceAnimator = new AbilitySliceAnimator(DisplayManager.getInstance().getDefaultDisplay(getContext()).get().getAttributes().width*GeneralUtil.SliceAnimatorDepth,0,0,0);
                abilitySliceAnimator.setDuration(GeneralUtil.SliceAnimatorDuration);
                getAbility().setAbilitySliceAnimator(abilitySliceAnimator);
            }catch (Exception ex){ex.printStackTrace();}
        }
    }

    public static void setBottomSlidable(boolean SlidingPossible)
    {
        EnableBottomSlide = SlidingPossible;
        AllPages.setSlidingPossible(SlidingPossible);
    }

    /*public AnimatorValue animatorValue()
    {
        //创建数值动画对象
        AnimatorValue mAnimatorValue = new AnimatorValue();
        //动画时长
        mAnimatorValue.setDuration(1000);
        //播放前的延迟时间
        mAnimatorValue.setDelay(0);
        //循环次数
        mAnimatorValue.setLoopedCount(0);
        //动画的播放类型
        mAnimatorValue.setCurveType(Animator.CurveType.LINEAR);
        //设置动画过程
        mAnimatorValue.setValueUpdateListener(new AnimatorValue.ValueUpdateListener()
        {
            @Override
            public void onUpdate(AnimatorValue animatorValue, float value)
            {
                if(value>=1f)
                    mAnimatorValue.release();
                else
                    AllContent.setAlpha(value);
            }
        });
        return mAnimatorValue;
    }*/

    @Override
    public void onStart(Intent intent)
    {
        Instance = this;
        AllPages = null;
        EnableBottomSlide = false;
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_slice_mainscene);
        //设定状态栏沉浸
        getWindow().setStatusBarColor(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_statusbar_normal,0xF7EDD8));
        getWindow().setNavigationBarColor(ResourceTool.getColor(this, ResourceTable.Color_dawnlighti_navigationbar_bottom, 0xF5F1E6));
        GeneralUtil.setWindowToMaxRefreshRate(getWindow());
        DisplayAttributes displayAttributes = DisplayManager.getInstance().getDefaultDisplay(getContext()).get().getAttributes();
        if(displayAttributes.width>displayAttributes.height)
        {
            getWindow().addFlags(WindowManager.LayoutConfig.MARK_TRANSLUCENT_STATUS|WindowManager.LayoutConfig.MARK_TRANSLUCENT_NAVIGATION|WindowManager.LayoutConfig.MARK_FULL_SCREEN);
        }
        eventHandler = new InitPageHandler(EventRunner.current());
        current_Direction = getResourceManager().getConfiguration().direction;
        ThemesEditorAbility.isMainSceneSlice = true;
        ThemesEditorAbility.Instance.MainSceneSlice = this;
        runner = EventRunner.create(true);
        myHandler = new MyEventHandler(runner);
        int CurrentColorMode = getColorMode();
        if(CurrentColorMode == 0) this.getWindow().setStatusBarVisibility(0);
        else if(CurrentColorMode == 1) this.getWindow().setStatusBarVisibility(2052);
        this.getWindow().setBackgroundColor(RgbColor.fromArgbInt(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_statusbar_normal,0xFEEFF4)));

        int index = 1;
        DatabaseManager.Init(this);
        if(!ThemesEditorAbility.QuitBySelf_Last) index = DatabaseManager.getInt("BottomBarIndex",1);
        else DatabaseManager.setInt("BottomBarIndex",index);
        String LastAbilityName = DatabaseManager.getString("LastAbilityName","None");

        if(ThemesEditorAbility.QuitBySelf_Last)
        {
            if(!LastAbilityName.equals("None"))
            {
                initPage(index);
                pageSwiper.onClickNewScene(LastAbilityName,true);
            }else
                eventHandler.sendEvent(index,6, EventHandler.Priority.IMMEDIATE);
        }
        else
        {
            if(index != 1)
            {
                if(!LastAbilityName.equals("None"))
                {
                    initPage(index);
                    pageSwiper.onClickNewScene(LastAbilityName,false);
                }else
                {
                    eventHandler.removeAllEvent();
                    eventHandler.sendEvent(index,20, EventHandler.Priority.IMMEDIATE);
                }
            }else
            {
                if(!LastAbilityName.equals("None"))
                {
                    initPage(index);
                    pageSwiper.onClickNewScene(LastAbilityName,true);
                }
                else
                {
                    eventHandler.removeAllEvent();
                    eventHandler.sendEvent(index,20, EventHandler.Priority.IMMEDIATE);
                }
            }
        }

        try
        {
            Intent e = new Intent();
            //通过Intent中的OperationBuilder类构造operation对象，指定设备标识（空串表示当前设备）、应用包名、Ability名称
            Operation operation = new Intent.OperationBuilder()
                    .withBundleName("com.agger.harmonyosthemeseditor")
                    .withAbilityName("com.agger.harmonyosthemeseditor.abilities.PreloadServiceAbility")
                    .build();
            // 把operation设置到intent中
            e.setOperation(operation);
            startAbility(e);
        }catch (Exception ex){}

        new AbilitySliceAnimatorHandler(EventRunner.create(true)).sendEvent(0,20, EventHandler.Priority.IMMEDIATE);

        /*暂不需要添加快捷方式，此功能代码暂时作为注释备用
        ShortcutInfo shortcutInfo = new ShortcutInfo();
        shortcutInfo.setBundleName("com.agger.harmonyosthemeseditor");
        shortcutInfo.setHostAbilityName("com.agger.harmonyosthemeseditor.ThemesEditorAbility");
        shortcutInfo.setLabel(ResourceTool.getString(this,ResourceTable.String_Special_ThemesBlindBox,"主题盲盒"));
        ShortcutIntent shortcutIntent = new ShortcutIntent();
        shortcutIntent.setTargetBundle("com.agger.harmonyosthemeseditor");
        shortcutIntent.setTargetClass("com.agger.harmonyosthemeseditor.ThemesEditorAbility");
        shortcutIntent.addParam("sharing_fa_extra_info","ShareFa_BlindBox");
        shortcutInfo.setIntent(shortcutIntent);
        GeneralUtil.writeResourceToFile(this,ResourceTable.Media_ApplicationIcon,getFilesDir()+"/icon.png");
        shortcutInfo.setIcon(getFilesDir()+"/icon.png");
        shortcutInfo.setId("Agi_BlindBox");
        getBundleManager().addHomeShortcut(shortcutInfo);*/
    }

    private ArrayList<TitleSwiper.DataItem> getAllTitles()
    {
        ArrayList<TitleSwiper.DataItem> dataItems = new ArrayList<>();
        dataItems.add(new TitleSwiper.DataItem(ResourceTool.getString(this,ResourceTable.String_actionbar_text_home,"快速指南")));
        dataItems.add(new TitleSwiper.DataItem(ResourceTool.getString(this,ResourceTable.String_actionbar_text_industry,"智慧工坊")));
        dataItems.add(new TitleSwiper.DataItem(ResourceTool.getString(this,ResourceTable.String_actionbar_text_more,"更多精彩")));
        return dataItems;
    }

    private ArrayList<PageSwiper.DataItem> getAllPages()
    {
        ArrayList<PageSwiper.DataItem> dataItems = new ArrayList<>();
        dataItems.add(new PageSwiper.DataItem(ResourceTable.Layout_page_home));
        dataItems.add(new PageSwiper.DataItem(ResourceTable.Layout_page_industry));
        dataItems.add(new PageSwiper.DataItem(ResourceTable.Layout_page_more));
        return dataItems;
    }

    PageSlider.PageChangedListener pageChangedEvent = new PageSlider.PageChangedListener()
    {
        @Override
        public void onPageSliding(int i, float v, int i1) {try{pageSwiper.PauseImageSwiper_Industry(true);}catch (Exception e){}}
        @Override
        public void onPageSlideStateChanged(int i) {}
        @Override
        public void onPageChosen(int i)
        {
            try
            {
                int o = AllPages.getCurrentPage();
                if(o == 0)onClickHome();
                else if(o==1)onClickIndustry();
                else if(o==2)onClickMore();
                else onClickIndustry();
            }catch (Exception ex){}
        }
    };

    private void initPage(int index)
    {
        try
        {
            //AllContent = findComponentById(ResourceTable.Id_AllContent_MainScene);
            AllTitles = (PageSlider)findComponentById(ResourceTable.Id_TitleSlider_MainScene);
            AllTitles.setProvider(new TitleSwiper(getAllTitles(),this));
            AllTitles.setSlidingPossible(false);
            AllPages = (PageSlider)findComponentById(ResourceTable.Id_PageSlider_MainScene);
            pageSwiper = new PageSwiper(getAllPages(),this);
            pageSwiper.mainSceneSlice = this;
            AllPages.setProvider(pageSwiper);
            AllPages.setReboundEffect(true);
            AllPages.setPageSwitchTime(150);
            AllTitles.setPageSwitchTime(150);
            text_home = (Text)findComponentById(ResourceTable.Id_Bottom_Text_Home);
            text_industry = (Text)findComponentById(ResourceTable.Id_Bottom_Text_Industry);
            text_more = (Text)findComponentById(ResourceTable.Id_Bottom_Text_More);
            image_home = (Image)findComponentById(ResourceTable.Id_Bottom_Image_Home);
            image_industry = (Image)findComponentById(ResourceTable.Id_Bottom_Image_Industry);
            image_more = (Image)findComponentById(ResourceTable.Id_Bottom_Image_More);

            if(index == 0)
            {
                pageSwiper.PauseImageSwiper_Industry(false);
                image_home.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_home_checked));
                image_industry.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_industry));
                image_more.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_more));
                text_home.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_bottom_text_accent,0xE08905)));
                text_industry.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
                text_more.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
            }
            else if(index == 1)
            {
                AllPages.setCurrentPage(1,false);
                AllTitles.setCurrentPage(1,false);
                image_home.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_home));
                image_industry.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_industry_checked));
                image_more.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_more));
                text_home.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
                text_industry.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_bottom_text_accent,0xE08905)));
                text_more.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
            }else if(index == 2)
            {
                pageSwiper.PauseImageSwiper_Industry(false);
                AllPages.setCurrentPage(2,false);
                AllTitles.setCurrentPage(2,false);
                image_home.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_home));
                image_industry.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_industry));
                image_more.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_more_checked));
                text_home.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
                text_industry.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
                text_more.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_bottom_text_accent,0xE08905)));
            }

            Component icon_home = findComponentById(ResourceTable.Id_Bottom_Icon_Home);
            Component icon_industry = findComponentById(ResourceTable.Id_Bottom_Icon_Industry);
            Component icon_more = findComponentById(ResourceTable.Id_Bottom_Icon_More);
            icon_home.setClickedListener(c->
            {
                System.gc();
                int CurrentPage = AllPages.getCurrentPage();
                if(CurrentPage != 0)
                {
                /*暂不使用过渡动画，作为储备能力留存
                try{if(animator!=null)animator.release();}catch(Exception ex){}
                AllContent.setAlpha(0f);
                animator = animatorValue();
                animator.start();*/
                    //PageSlider执行setCurrentPage时，会对每个page执行销毁再重绘，但是当前PageSlider内部page过于复杂，销毁重绘会严重影响setCurrentPage速度
                    //因此我们手动禁止它销毁和重绘，然后在执行setCurrentPage时，模拟Sliding方式切换页面，即修改PageSlider下级的DirectionalLayout组件的坐标
                    //修改完PageSlider下级的DirectionalLayout组件的坐标后，虽然已完成页面切换，但是很快会弹回原来的位置，这是因为PageSlider内部记忆的当前page值并没有变更，所以我们还是要继续执行setCurrentPage的
                    //PageSlider为横向时，下级的DirectionalLayout组件高度与其包含的每个ComponentContainer一致，宽度为所有包含的ComponentContainer之和，也就是parent组件PageSlider的宽度乘以下级组件数量
                    AllPages.setCurrentPage(0,EnableBottomSlide);
                    onClickHome();
                }
                System.gc();
            });
            icon_industry.setClickedListener(c->
            {
                System.gc();
                int CurrentPage = AllPages.getCurrentPage();
                if(CurrentPage != 1)
                {
                /*暂不使用过渡动画，作为储备能力留存
                try{if(animator!=null)animator.release();}catch(Exception ex){}
                AllContent.setAlpha(0f);
                animator = animatorValue();
                animator.start();*/
                    image_home.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_home));
                    image_industry.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_industry_checked));
                    image_more.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_more));
                    text_home.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
                    text_industry.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_bottom_text_accent,0xE08905)));
                    text_more.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
                    AllPages.removePageChangedListener(pageChangedEvent);
                    //PageSlider执行setCurrentPage时，会对每个page执行销毁再重绘，但是当前PageSlider内部page过于复杂，销毁重绘会严重影响setCurrentPage速度
                    //因此我们手动禁止它销毁和重绘，然后在执行setCurrentPage时，模拟Sliding方式切换页面，即修改PageSlider下级的DirectionalLayout组件的坐标
                    //修改完PageSlider下级的DirectionalLayout组件的坐标后，虽然已完成页面切换，但是很快会弹回原来的位置，这是因为PageSlider内部记忆的当前page值并没有变更，所以我们还是要继续执行setCurrentPage的
                    //PageSlider为横向时，下级的DirectionalLayout组件高度与其包含的每个ComponentContainer一致，宽度为所有包含的ComponentContainer之和，也就是parent组件PageSlider的宽度乘以下级组件数量
                    AllPages.setCurrentPage(1,EnableBottomSlide);
                    AllTitles.setCurrentPage(1,EnableBottomSlide);
                    pageSwiper.ContinueImageSwiper_Industry();
                    DatabaseManager.Init(this);
                    DatabaseManager.setInt("BottomBarIndex",1);
                    AllPages.addPageChangedListener(pageChangedEvent);
                }
                System.gc();
            });
            icon_more.setClickedListener(c->
            {
                System.gc();
                int CurrentPage = AllPages.getCurrentPage();
                if(CurrentPage != 2)
                {
                /*暂不使用过渡动画，作为储备能力留存
                try{if(animator!=null)animator.release();}catch(Exception ex){}
                AllContent.setAlpha(0f);
                animator = animatorValue();
                animator.start();*/
                    //PageSlider执行setCurrentPage时，会对每个page执行销毁再重绘，但是当前PageSlider内部page过于复杂，销毁重绘会严重影响setCurrentPage速度
                    //因此我们手动禁止它销毁和重绘，然后在执行setCurrentPage时，模拟Sliding方式切换页面，即修改PageSlider下级的DirectionalLayout组件的坐标
                    //修改完PageSlider下级的DirectionalLayout组件的坐标后，虽然已完成页面切换，但是很快会弹回原来的位置，这是因为PageSlider内部记忆的当前page值并没有变更，所以我们还是要继续执行setCurrentPage的
                    //PageSlider为横向时，下级的DirectionalLayout组件高度与其包含的每个ComponentContainer一致，宽度为所有包含的ComponentContainer之和，也就是parent组件PageSlider的宽度乘以下级组件数量
                    AllPages.setCurrentPage(2,EnableBottomSlide);
                    onClickMore();
                }
                System.gc();
            });

            EnableBottomSlide = DatabaseManager.getString("EnableBottomSlide","No").equals("Yes");
            AllPages.setSlidingPossible(EnableBottomSlide);
            AllPages.addPageChangedListener(pageChangedEvent);
        }catch (Exception ex){}
    }

    @Override
    public void onBackPressed()
    {
        if (!ThemesEditorAbility.isQuitMode)
        {
            try {Toast_QuitApplication = getResourceManager().getElement(ResourceTable.String_Toast_QuitApplication).getString();}
            catch (Exception ex) {}
            new GeneralToast(this).setText(Toast_QuitApplication).show();
            ThemesEditorAbility.isQuitMode = true;
            myHandler.sendEvent(0, 1200, EventHandler.Priority.IMMEDIATE);
        } else if (ThemesEditorAbility.isQuitMode)
        {
            DatabaseManager.Init(this);
            DatabaseManager.setString("QuitBySelf","Yes");
            ThemesEditorAbility.isMainSceneSlice = false;
            if(ThemesEditorAbility.EnableWallpaperFadeEffect)
            {
                try
                {
                    WallpaperController wallpaperController = WallpaperController.getInstance(this);
                    if(new File(getFilesDir()+"/user_wallpaper.jpg").exists())
                        wallpaperController.setWallpaper(new FileInputStream(getFilesDir()+"/user_wallpaper.jpg"),WallpaperController.WALLPAPER_SYSTEM);
                }catch(Exception e){e.printStackTrace();}
            }
            if(PreloadServiceAbility.isFinished) ProcessManager.kill(ProcessManager.getPid());
            else terminateAbility();
        }
    }

    @Override
    protected void onStop()
    {
        try{pageSwiper.EndImageSwiper_Industry();}catch (Exception e){}
        try{myHandler.removeAllEvent();}catch (Exception e){}
        try{eventHandler.removeAllEvent();}catch (Exception e){}
        runner = null;
        myHandler = null;
        eventHandler = null;
        Toast_QuitApplication = null;
        AllTitles = null;
        AllPages = null;
        pageSwiper = null;
        text_home = null;
        text_industry = null;
        text_more = null;
        image_home = null;
        image_industry = null;
        image_more = null;
        //AllContent = null;
        System.gc();
        super.onStop();
    }

    public void onClickHome()
    {
        try
        {
            image_home.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_home_checked));
            image_industry.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_industry));
            image_more.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_more));
            text_home.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_bottom_text_accent,0xE08905)));
            text_industry.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
            text_more.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
            AllTitles.setCurrentPage(0,EnableBottomSlide);
            pageSwiper.PauseImageSwiper_Industry(true);
            DatabaseManager.Init(this);
            DatabaseManager.setInt("BottomBarIndex",0);
        }catch (Exception ex){}
    }

    public void onClickIndustry()
    {
        try
        {
            image_home.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_home));
            image_industry.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_industry_checked));
            image_more.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_more));
            text_home.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
            text_industry.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_bottom_text_accent,0xE08905)));
            text_more.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
            AllTitles.setCurrentPage(1,EnableBottomSlide);
            DatabaseManager.Init(this);
            DatabaseManager.setInt("BottomBarIndex",1);
        }catch (Exception ex){}
    }

    public void onClickMore()
    {
        try
        {
            image_home.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_home));
            image_industry.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_industry));
            image_more.setImageElement(new VectorElement(this,ResourceTable.Graphic_ic_more_checked));
            text_home.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
            text_industry.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_primary_text,0x000000)));
            text_more.setTextColor(new Color(ResourceTool.getColor(this,ResourceTable.Color_dawnlighti_bottom_text_accent,0xE08905)));
            AllTitles.setCurrentPage(2,EnableBottomSlide);
            pageSwiper.PauseImageSwiper_Industry(true);
            DatabaseManager.Init(this);
            DatabaseManager.setInt("BottomBarIndex",2);
        }catch (Exception ex){}
    }

    @Override
    public void onActive() { super.onActive(); }

    @Override
    public void onForeground(Intent intent) { super.onForeground(intent); }
}